﻿<%@ CODEPAGE=65001 %>
<% Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../../zb_system/function/c_function.asp" -->
<!-- #include file="../../../zb_system/function/c_system_lib.asp" -->
<!-- #include file="../../../zb_system/function/c_system_base.asp" -->
<!-- #include file="../../../zb_system/function/c_system_plugin.asp" -->
<!-- #include file="../p_config.asp" -->
<%
Call System_Initialize()

If CheckpluginState("downloadcounter") = False Then Call ShowError(48)

Dim id
If Request.QueryString("id") = Empty Or IsNumeric(Request.QueryString("id")) = False Then
    Call ShowError(3)
Else
    id = CInt(Request.QueryString("id"))
End If

Dim temprs,num,filename,filepath,objADO
Set temprs = objConn.Execute("select * FROM blog_UpLoad WHERE [ul_ID]="&id)
num = temprs("ul_DownNum")+1
filename = temprs("ul_FileName")
filepath = ZC_UPLOAD_DIRECTORY &"/"&Year(temprs("ul_PostTime")) & "/" & Month(temprs("ul_PostTime")) & "/"& temprs("ul_FileName")
filepath = Server.mappath("../../../"&filepath)
Set temprs = Nothing

objConn.Execute("UPDATE blog_UpLoad SET [ul_DownNum]="&num&" WHERE [ul_ID]="&id)

Response.Clear
Response.ContentType = "application/octet-stream "
Response.AddHeader "Content-Disposition",   "attachment;filename="& filename
Set objADO=Server.CreateObject("ADODB.Stream")
With objADO
	.Type=adTypeBinary
	.Mode=adModeReadWrite
	.Open
	.Position = objAdo.Size
	.LoadFromFile filepath
	Response.BinaryWrite .Read
	.Close
End With
Response.End
Set objADO=Nothing

Call System_Terminate()
%>